package netty.nio;

import java.nio.IntBuffer;

/**
 * @Author: zhangrongqing
 * @Date: 2020/1/6 13:21
 */
//举例说明buffer的使用
public class BasicBuffer {
    public static void main(String[] args) {
        IntBuffer intBuffer = IntBuffer.allocate(5);

        for (int i = 0; i < intBuffer.capacity(); i++) {
            intBuffer.put(i);
        }

        //buffer读写切换
        intBuffer.flip();

//        for (int i = 0; i < intBuffer.capacity(); i++) {
//            System.out.println(intBuffer.get());
//        }

        while(intBuffer.hasRemaining()){
            System.out.println(intBuffer.get());
        }
    }
}
